package com.cj.td.screen.actor;

import org.loon.framework.android.game.action.ActionListener;
import org.loon.framework.android.game.action.FadeTo;
import org.loon.framework.android.game.core.graphics.component.Actor;
import org.loon.framework.android.game.core.graphics.component.ActorLayer;
import org.loon.framework.android.game.core.graphics.opengl.GLColor;
import org.loon.framework.android.game.core.graphics.opengl.GLEx;

public class Turret extends Actor{
	
	private int range = 50;
	
	private int delay = 10;
	
	private long fieldWidth;
	
	private long fieldHeight;
	
	boolean selected;
	
	public Turret(String fileName,long fieldWidth,long fieldHeight){
		setImage(fileName);
		this.fieldWidth = fieldWidth;
		this.fieldHeight = fieldHeight;
		
		
		setDelay(100);
		setAlpha(0);
	}

	@Override
	protected void addLayer(ActorLayer gameLayer) {
		//让角色渐进式出现
		FadeTo fade = fadeOut();
		//监听渐进淡出事件
		fade.setActionListener(new ActionListener() {
			
			@Override
			public void stop(Actor arg0) {
				//旋转90度
				rotateTo(90);
			}
			
			@Override
			public void start(Actor arg0) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void process(Actor arg0) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	@Override
	public void draw(GLEx g) {
		if(selected){
			g.setColor(255, 0, 0, 100);
			g.fillOval(-(range*2-fieldWidth)/2
					, -(range*2-fieldHeight)/2
					, range
					, range);
			g.setColor(GLColor.red);
			g.drawOval(-(range*2-fieldWidth)/2
					, -(range*2-fieldHeight)/2
					, range
					, range);
			g.resetColor();
		}
	}

	@Override
	public void action(long elapsedTime) {
		
	}

}
